package com.study.redis.user.controller;

import com.study.redis.user.domain.User;
import com.study.redis.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.Cookie;

/**
 * Created by hegy on 2018/6/4.
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("register")
    public String addUser(User user){
        String result = "";
        if (userService.insert(user) == 1) {
            result = "login/login";
        } else {
            result = "login/register";
        }
        return result;
    }
}
